package alibaba.ifelserefactor.demo01.test04;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static alibaba.ifelserefactor.demo01.ShareType.*;

/**
 * @author ChangLiang
 * @date 2020/4/20
 */
@Slf4j
public class ShareServiceTest {

    /**
     * 这种情况，前端只需要了解一个统一的request，以及一个方法，应该是最小了解 符合迪米特法则了
     *
     */

    @Test
    @DisplayName("前端调用分享link 只需要了解这个方法")
    public void test() {
        ShareItemRequest request = new ShareItemRequest();
        request.type = TYPE_LINK;
        ShareItem shareItem = ShareItemFactory.createShareItem(request);
        ShareService shareService = new ShareService();
        shareService.share(shareItem, (state, msg) -> log.info(msg));
    }

    @Test
    @DisplayName("前端调用分享Text 只需要了解这个方法")
    public void test2() {
        ShareItemRequest request = new ShareItemRequest();
        request.type = TYPE_TEXT;
        ShareItem shareItem = ShareItemFactory.createShareItem(request);
        ShareService shareService = new ShareService();
        shareService.share(shareItem, (state, msg) -> log.info(msg));
    }
}
